# -*- coding: utf-8 -*-
# Tubedl video indirme fonksiyonları
  #Copyright (C) 2007 - 2008
  #Oğuzhan Eroğlu (oguzhan@oguzhaneroglu.com)
  #Mk18(mertk18@gmail.com)
  #This program is free software: you can redistribute it and/or modify
  #it under the terms of the GNU General Public License as published by
  #the Free Software Foundation, either version 3 of the License, or
  #(at your option) any later version.

  #This program is distributed in the hope that it will be useful,
  #but WITHOUT ANY WARRANTY; without even the implied warranty of
  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  #GNU General Public License for more details.

import re

destek = ("youtube.com", "izlesene.com", "vidivodo.com")

class API:
	def __init__(self):
		pass
	def youtube_com(self, kaynak):
		self.paramr = re.compile("var swfArgs.*").findall(kaynak)[0]
		self.param = re.compile('"t": "(.*?)"').findall(self.paramr)[0]
		self.video_id = re.compile('"video_id": "(.*?)"').findall(self.paramr)[0]
		return "http://youtube.com/get_video.php?video_id="+self.video_id+"&t="+self.param
	def izlesene_com(self, kaynak):
		self.flv = re.compile("(http://.*?.flv)").findall(kaynak)
		self.flv_dl = self.flv[1]
		return self.flv_dl
	def vidivodo_com(self, kaynak):
		self.url_flv = re.compile("vidservers/server../videos/.{4}/../../../.{22}.flv")
		self.flv = self.url_flv.findall(kaynak)
		self.flv_dl = "http://www.vidivodo.com/%s" % (self.flv[0])
		return self.flv_dl